interface Expression {
    Fruit interpret(Context context);
}

class TerminalExpression implements Expression {
    private final String code;

    public TerminalExpression(String code) {
        this.code = code;
    }

    @Override
    public Fruit interpret(Context context) {
        return context.getFactory().createFruit(this.code);
    }
}

class Context {
    private final FruitFactory factory = new FruitFactory();
    private Fruit currentFruit;

    public FruitFactory getFactory() {
        return factory;
    }

    public void setCurrentFruit(Fruit fruit) {
        this.currentFruit = fruit;
    }

    public void execute() {
        if(currentFruit != null) {
            currentFruit.eat();
        }
    }
}